<!DOCTYPE htm PUBLIC "-//W3C//DTD Xhtm 1.0 Transitional//EN" "DTD/xhtm1-transitional.dtd">
<htm xmlns="http://www.w3.org/1999/xhtm" xml:lang="de" lang="de">
<head>
 <meta http-equiv="content-type" content="text/htm; charset=iso-8859-1" />
 <meta http-equiv="content-style-type" content="text/css" />
 <meta name="author" content="Arlsair" />
 <meta name="date" content="2004-01-22" />
 <title>SimpleResize</title>
 <link rel="stylesheet" type="text/css" href="../../style.css" />
</head><body>
<h1>SimpleResize</h1>

<h2>&Uuml;bersicht</h2>
<b>Autor:</b> Tom Barry<br />
<b>Version:</b> 0.3.3.0<br />
<b>Download:</b> <a href="http://mywebpages.comcast.net/trbarry/downloads.htm" target="_blank">http://mywebpages.comcast.net/trbarry/downloads.htm</a><br />
<b>Kategorie:</b> Resizer<br />
<b>Anforderungen:</b> YV12 oder YUY2 Farbformat<br />
<hr>
<h2>Description</h2>
SimpleResize is an Avisynth filter that will do a very simple 2 tap linear interpolation. It is unfiltered which means it will not soften much.
<br>
<br>
<b>
InterlacedResize</b> &amp; <b> InterlacedWarpedResize</b> are designed to work on interlaced
materiel ( more at the end of the doc )<br>
<p>It's main advantage is that it will run somewhat faster than some of the others.<br>
  <br>
  <strong>To use it just</strong>:</p>
<p> In you Avisynth file use command similar to </p>
<pre>LoadPlugin(&quot;F:\SimpleResize\SimpleResize.dll&quot;)
Avisource(&quot;D:\wherever\myfile.avi&quot;)
SimpleResize(width, height)</pre>
<p> Of course replace the file and directory names with your own and supply the
  integer values for <strong>width</strong> &amp; <strong>height</strong>. </p>
<p>SimpleResize should run on all MMX machines. It has also has some added (optional)
code for SSE2 instructions for when it is running on a P4 and some SSEMMX for
  P3 &amp; Athlon, though it could maybe use some more. But sorry, no plans for extra
  3DNow code.</p>
<p>***************</p>
<p><br>
  <strong>WarpedResize</strong></p>
<p>WarpedResize is also included in the SimpleResize.dll. WarpedResize will do
  a non-linear stretch/squeeze in both the horizontal and vertical dimensions. This can be
  useful when you want to change the aspect ratio of a video clip and have it mostly distorted
  at the top, bottom, and side edges. This is mostly experimental but I added it because
  it required few code changes and almost Zero performance penalty. Use as:</p>
<pre>LoadPlugin(&quot;F:\SimpleResize\SimpleResize.dll&quot;)
Avisource(&quot;D:\wherever\myfile.avi&quot;)
WarpedResize(width, height, hWarp, vWarp)</pre>
<p>where <strong>hWarp</strong> &amp; <strong>vWarp</strong> are the horizontal
  and vertical warp factors. These are real number, usually between .8 and 1.3 that determine how non-linear you really want the
  output to be.</p>
<p>Values above 1.0 cause the output image to be stretched more in the middle
  and squeezed at the edges. Values below 1.0 will do the reverse. Specifying 1.0 for either
  of them will do a linear resize in that dimension, just as you would get using SimpleResize.
Values far from 1.0 will give some very strange results. See the &quot;Notes
  to Mathematicians&quot; below.</p>
<p>One reason to use WarpedResize would be when you have a clip with a 16:9 aspect
  ratio and want to resize it for a 4:3 aspect ratio display without either clipping off
  valuable info or having to display black bars. (or vice versa)<br>
  ----------------</p>
<p></p>
<p>An example image of using WarpedResize for this can be found (for now) at <a href="http://www.trbarry.com/WarpTest.jpg">www.trbarry.com/WarpTest.jpg</a>.
  This image was from a short HDTV digital capture that was at a 1280x720 resolution, a 16:9 aspect ratio. It was downsized and warped to
  a 640x480 4:3 aspect ratio using the following script command:</p>
<pre>WarpedResize(640,480,1.15,0.95))</pre>
<p>Also, for an example of a 4:3 capture warped to fit on a 16:9 screen see <a href="http://www.trbarry.com/WarpTest2.jpg">www.trbarry.com/WarpTest2.jpg</a><br>
  <br>
  -----------------</p>
<p><strong>Current limitations, for SimpleResize/WarpedResize</strong>:</p>
<p>1) Only YUY2 color mode is currently supported. Add a ConvertToYuY2 command
  first if needed.</p>
<p>2) The target width NO LONGER must be a multiple of 4 pixels.</p>
<p>3) It will run faster on SSE2 machines if the target width is a multiple of
  8 pixels and if the data starts on an 8 pixel boundary. I don't know if prior Clip()
  commands affect this or not.</p>
<p>4) If anyone knows how to make a DirectShow filter out of this I'd sure like
  to have one. ;-)</p>
<p><br>
  <strong>Notes to Mathematicians: (and questions)</strong></p>
<p>Imagine the screen was dimensions that went from -1.0 to 1.0. We'll only consider
  the horizontal dimension for the moment and only the right hand half of the screen.
  Assume we want to calculate the value of an output pixel at location x, where 0 &lt;=
  x &lt;=1.</p>
<p>The output value will be the source value from the input screen with the same
  dimensions, at location s. Right now I'm just calculating s = (1-w) * x^3 + w * x, where w
  is the warp factor mentioned above (Later note: w = 2 - warp factor, for compat with first release).
  This gets the job done and produces smooth numbers from 0 to one, without too much
distortion
  as long as w is close to 1.0. </p>
<p>The same formula is reflected for the left half of the screen.</p>
<p><br>
  The warp equations are designed to:<br>
  <br>
  * Always be rising but yield results from 0 to 1</p>
<p>* Have a first derivative that doesn't go to 0 or infinity, at least close to the center of the screen</p>
<p>* Have a curvature (absolute val of 2nd derivative) that is small in the center and smoothly rises towards the edges. We would like the curvature
to be everywhere = 0 when the warp factor = 1</p>
<p>Now, as near as I can tell the curvature is more or less just the absolute
  value of the second derivative. So if we wanted the curvature to be small when x = 0 and
  to grow toward the edges, what could be a useful warp function? The above function already
represents a change since V 0.1 but I'm still not so sure it's the best. </p>
<p>It is easy to drop in another warp function. And there is no performance penalty
either way because it's just calculated and tabled at startup. After that it
  runs at the same speed as SimpleResize.</p>
<p>Anyone have any ideas? (Anybody care about this part?)</p>
<p>***************</p>
<p><br>
  <strong>InterlacedResize and InterlacedWarpedResize</strong></p>
<p>If you want to resize an interlace source you can instead use:</p>
<pre>InterlacedResize(width, height)</pre>
<p>or</p>
<pre>InterlacedWarpedResize(width, height, hWarp, vWarp)</pre>
<p>These have the same paramaters as before but are designed to operate on interlaced
  source, without either blending even/odd data or messing up the coordinates because
  of the even/odd line offsets. Theoretically these can lose a small amount of vertical
  detail or confuse a subsequent deinterlace or IVTC function but so far in my own testing
  I have not found it to be a problem.</p>
<p>So if you intend to keep your video in interlaced form, certainly use these.
  And if you are downsizing you may find that doing the InterlacedResize first before
  a more costly deinterlacing step can give you a small performance advantage on other
  material. But this is still experimental. YMMV.
</p>
</body>
</html>
